/******************************************************************************

Welcome to GDB Online.
  GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
  C#, OCaml, VB, Perl, Swift, Prolog, Javascript, Pascal, COBOL, HTML, CSS, JS
  Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <iostream>
#include <string>

int main() {
    std::string s;
    std::cout << "Введите скобочную последовательность ";
    std::cin >> s;
    std::string a = "";
    
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '[' || s[i] == ']' || s[i] == '(' || s[i] == ')' || s[i] == '{' || s[i] == '}' || s[i] == '<' || s[i] == '>') {
            a = a + s[i];
        }
    }
    
    while (s.find("()") != std::string::npos || s.find("{}") != std::string::npos || s.find("[]") != std::string::npos || s.find("<>") != std::string::npos) {
        if (s.find("()") != std::string::npos) {
            s.replace(s.find("()"), 2, "");
        }
        if (s.find("{}") != std::string::npos) {
            s.replace(s.find("{}"), 2, "");
        }
        if (s.find("[]") != std::string::npos) {
            s.replace(s.find("[]"), 2, "");
        }
        if (s.find("<>") != std::string::npos) {
            s.replace(s.find("<>"), 2, "");
        }
    }
    
    if (s == "") {
        std::cout << "True" << std::endl;
    }
    if (s != "") {
        std::cout << "false" << std::endl;
    }

    return 0;
}